package com.dgty.dg_common.util

import android.text.TextUtils

/**
 * Title: ValidUtil.kt
 * Description:正则校验工具
 * Created DateTime: 2023-03-13
 * Created by xxl.
 */
class ValidUtil {
    companion object {
        //是否手机号
        fun isMobileNO(mobiles: String): Boolean {
            val telRegex = Regex("^1[3|4|5|6|7|8|9][0-9]\\d{8}$")
            return if (TextUtils.isEmpty(mobiles)) false else mobiles.matches(telRegex)
        }

        //是否中文名字
        fun isChineseName(name: String): Boolean {
//            val nameRegex = Regex("[\u4e00-\u9fa5▪•]+")
            val nameRegex = Regex("^[\u4e00-\u9fa5·\u36c3\u4DAE]{0,}$")
            return if (TextUtils.isEmpty(name)) false else name.matches(nameRegex)
        }

        //是否是地址支持中文 英文 数字
        fun isAddress(addr: String): Boolean {
            val nameRegex = Regex("[\u4e00-\u9fa5|a-zA-Z|0-9]+")
            return if (TextUtils.isEmpty(addr)) false else addr.matches(nameRegex)
        }
        //是否是密码
        fun isPsw(addr: String): Boolean {
            val nameRegex = Regex("[-|a-zA-Z|0-9]{6,20}")
            return if (TextUtils.isEmpty(addr)) false else addr.matches(nameRegex)
        }
    }
}